<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
include("db/connect.php");
$selectprovince="SELECT * FROM province ORDER BY province_name ASC";
$queryprovince=mysql_query($selectprovince);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="js/jquery.js"></script>
<script>$(document).ready(function() {
    $("#province_id").change(function(){
		if($("#province_id").val()==1234){
			alert("โปรดเลือกจังหวัด");
			$("#amphur_id").html('');
			$("#amphur_id").html("<option value='1234'>โปรดเลือกจังหวัด</option>");
			$("#tambol_id").html('');
			$("#tambol_id").html("<option value='1234'>โปรดเลือกอำเภอ</option>");
			}
			else{
		$.ajax({
			type:"POST",
			url:"listamphur.php",
			data:"temp="+$("#province_id").val(),
			success: function(msg){
				$("#spaceamphur").html(msg);
				}
			});//ajax
			
			}//else
	});//province change
}); 
/*function amphur*/
function amphur_change(){
		$.ajax({
			type:"POST",
			url:"listtambon.php",
			data:"temp="+$("#amphur_id").val(),
			success: function(msg){
				$("#spacetambol").html(msg);
				}
			});//ajax
	}//amphurchange
</script>
<style type="text/css">
#fromInsert_Cus p {
	text-align: center;
	font-size: 36px;
}
</style>
</head>
<body>
<form id="fromInsert_Cus" name="fromInsert_Cus" method="post" action="Javascript:submitCus();">
  <p>ข้อมูลลูกค้า</p>
  <table width="528" border="0">
    <tr>
      <td width="178">ชื่อ</td>
      <td width="340">
      <input name="cus_name" type="text" id="cus_name" /></td>
    </tr>
    <tr>
      <td>นามสกุล</td>
      <td>
      <input name="cus_lastname" type="text" id="cus_lastname" /></td>
    </tr>
    <tr>
      <td>ที่อยู่</td>
      <td>
      <textarea name="cus_addr" id="cus_addr" cols="45" rows="3"></textarea></td>
    </tr>
    <tr>
      <td><label for="select">จังหวัด :</label></td>
      <td><select name="province_id" id="province_id">
        <option value="1234">โปรดเลือก</option>
        <?php 
	while($resultprovince=mysql_fetch_array($queryprovince)){
		?>
        <option value="<?php echo$resultprovince["province_id"]?>"><?php echo $resultprovince["province_name"]?></option>
        >
        <?php
        }
	?>
      </select></td>
    </tr>
    <tr>
      <td><label for="select7">อำเภอ :</label></td>
      <td><div id="spaceamphur"><select name="amphur_id" id="amphur_id">
        <option>โปรดเลือกจังหวัด</option>
      </select></div></td>
    </tr>
    <tr>
      <td><label for="select8"> ตำบล :</label></td>
      <td><div id="spacetambol"><select name="tambol_id" id="tambol_id">
        <option>โปรดเลือกอำเภอ</option>
      </select></div></td>
    </tr>
    <tr>
      <td>รหัสไปร์ษณีย์</td>
      <td>
      <input type="text" name="cus_postal" id="cus_postal" /></td>
    </tr>
    <tr>
      <td>เบอร์โทรศัพท์</td>
      <td>
      <input type="text" name="cus_tel" id="cus_tel" required="required"/></td>
    </tr>
    <tr>
      <td>E-mail</td>
      <td>
      <input type="email" name="cus_mail" id="cus_mail" required="required"/></td>
    </tr>
  </table>
  <p>
    <input type="submit" name="Submit" id="button" value="Submit" />
    <input type="reset" name="button2" id="button2" value="Reset" />
  </p>
  <p>&nbsp;</p>
</form>
<div id="spantest"></div>
่
</body>
</html>
